package cn.zymall.merchant.controller;


import cn.zymall.common.controller.crud.BaseController;
import cn.zymall.common.model.Coupon;
import cn.zymall.common.model.Merchant;
import cn.zymall.merchant.service.MerchantAccountService;
import cn.zymall.merchant.service.MerchantCouponService;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @ClassName MerchantCouponController
 * @Description TODO
 * @Author chenmei
 * @Date 2020/8/24 14:38
 * @Version 1.0
 **/
@RestController
@RequestMapping("/merchantCoupon")
public class MerchantCouponController extends BaseController<MerchantCouponService, Coupon> {

	@Autowired
	MerchantCouponService merchantCouponService;


	@GetMapping("/getAllCoupon")
	public List<Coupon> getAllCoupon() {
		return merchantCouponService.getAllCoupon();
	}


	@GetMapping("/updataCouponStatus/{couponId}/{couponStatus}")
	public void updataCouponStatus(@PathVariable(value = "couponId") Integer couponId , @PathVariable(value = "couponStatus") Integer couponStatus){
		merchantCouponService.updataCouponStatus(couponId,couponStatus);
	}


	@GetMapping("/getCouponById/{id}")
	public Coupon getCouponById(Integer couponId ){
		return merchantCouponService.getCouponById(couponId);
	}


	@GetMapping("/conditionQuery")
	public List<Coupon> conditionQuery( String couponName,Integer goodsType, Byte couponStatus){
		List<Coupon> list=merchantCouponService.conditionQuery(couponName,goodsType,couponStatus);
		System.out.println(list);
		return list;
	}


	@GetMapping("/getMerchantSingleCoupon")
	public Coupon getMerchantSingleCoupon(Integer merchantId) {
		return merchantCouponService.getMerchantSingleCoupon(merchantId);
	}

	@GetMapping("/getCouponByMerchantId")
	public List<Coupon> getCouponByMerchantId(Integer merchantId){

		return merchantCouponService.getCouponByMerchantId(merchantId);
	}
}
